Skip to content

Emit Kubernetes Events - #155

Open
HarshwardhanPatil07 wants to merge 4 commits into
bootc-dev:mainfrom
HarshwardhanPatil07:issue-101-k8s-events
Open

Emit Kubernetes Events#155
HarshwardhanPatil07 wants to merge 4 commits into
bootc-dev:mainfrom
HarshwardhanPatil07:issue-101-k8s-events

Conversation

@HarshwardhanPatil07

@HarshwardhanPatil07 HarshwardhanPatil07 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Pool Events:

  • ImageUpdateAvailable
  • RolloutStarted
  • RolloutCompleted
  • Warning Events when the pool enters or changes a degraded state

Node Events:

  • Staging
  • Staged
  • Rebooting
  • DrainFailed
  • DrainTakingTooLong

Node Events reference the BootcNode as the primary object and the owning BootcNodePool as the related object.

Testing

Completed: Manual Event verification on a bink cluster

make buildimg
make deploy-bink
make e2e V=1 RUN='TestUpdateReboot\|TestTagResolution'

watch events in second terminal: kubectl get events.events.k8s.io -A --watch

closes: #101

@HarshwardhanPatil07

Copy link
Copy Markdown
Collaborator Author

PTAL @Johan-Liebert1 @ptalgulk01 @alicefr

Comment thread test/e2e/bootcnode_test.go Outdated
Comment on lines +676 to +683
for _, event := range eventList.Items {
if event.Regarding.Kind == kind &&
event.Regarding.Name == name &&
event.Regarding.UID == uid {
events = append(events, event)
}
}
return events, nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have this as helper func something like

func FilterEventsByObject(items []eventsv1.Event, kind, name string, uid types.UID) []eventsv1.Event {
      out := make([]eventsv1.Event, 0, len(items))
      for _, e := range items {
              if e.Regarding.Kind == kind && e.Regarding.Name == name && e.Regarding.UID == uid {
                      out = append(out, e)
              }
      }
      return out
}

Comment thread internal/controller/events.go Outdated

switch idle.Reason {
case bootcv1alpha1.NodeReasonStaging:
return observation + ":" + node.Spec.DesiredImage,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have this store in var observation + ":" + node.Spec.DesiredImage

The controller may update BootcNode metadata while envtest simulates a daemon status update. Both operations advance resourceVersion, making a single Get followed by Status().Update susceptible to conflicts.

Use client-go RetryOnConflict so the simulated daemon refetches the latest BootcNode before retrying its status update.

Assisted-by: AI
Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Users currently need to inspect conditions and controller logs to understand image resolution, rollout progress, node transitions, and blocked drains. Emit Kubernetes Events for these meaningful observations without using Event delivery to drive reconciliation.

Reuse the existing image resolution and drain state paths, persist node transition bookkeeping in a controller-owned annotation, and bound Event notes to the events.k8s.io 1 KiB limit. Grant the recorder create and patch access to both supported Event API groups.

Related: bootc-dev#101

Assisted-by: AI
Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Exercise pool, node, and drain Event behavior with exact reason, action, relationship, and note assertions. Cover transition deduplication, annotation write failures, tag resolution, degraded status, drain scheduling, and UTF-8-safe note truncation.

Use envtest Event objects filtered by regarding UID so retained Events from an earlier object with the same name cannot satisfy the integration assertions.

Related: bootc-dev#101

Assisted-by: AI
Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Envtest does not exercise the deployed RBAC, Event broadcaster, daemon, or real reboot path. Extend the existing bink update and tag-resolution scenarios to assert the Events produced by a deployed operator.

Filter Events by the regarding object UID and verify exact types, reasons, actions, notes, and related pool identity.

Related: bootc-dev#101

Assisted-by: AI
Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
@HarshwardhanPatil07

Copy link
Copy Markdown
Collaborator Author

@ptalgulk01 Thanks. added the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit Kubernetes Events

2 participants